package com.wk.springboot.thread;

public class MyThread implements Runnable {

    private String name;

    private String obj;

    public MyThread(String name) {
        this.name = name;
    }

    public MyThread(String name, String obj) {
        this.name = name;
        this.obj = obj;
    }

    @Override
    public void run() {
        synchronized (obj){
            System.out.println(this.name+"开始运行");
            long start = System.currentTimeMillis();
            try {
//                obj.wait(5000);
//                Thread.sleep(5000);
                Thread.currentThread().join();
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName()+"被中断了！！！-------"+(System.currentTimeMillis()-start));
            }
            System.out.println(this.name+"运行完毕");
        }
    }
}
